﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DP.RecallDeal.Interface.Core
{
    /// <summary>
    /// Partner: ADP
    /// This is DTO which holds object pulled from ADP via F&I query
    /// </summary>
    [Serializable]
    public class VehicleSale : IDTO
    {
        #region dp_deals

        ///<summary>
        ///Accounting posting date
        ///</summary>        
        public string AccountingDate { get; set; }

        ///<summary>
        ///Vehicle age when sold
        ///</summary>        
        public string Age { get; set; }

        ///<summary>
        ///Accident and health insurance (A&H) premium
        ///</summary>        
        public string AHPremium { get; set; }

        ///<summary>
        ///Credit life insurance premium
        ///</summary>        
        public string CLPremium { get; set; }

        ///<summary>
        ///Co-buyer name
        ///</summary>        
        public string CoBuyer { get; set; }

        ///<summary>
        ///Vehicle sale deal number
        ///</summary>        
        public string DealNo { get; set; }

        ///<summary>
        ///Dealership profit on financing
        ///</summary>        
        public string FIIncome { get; set; }

        ///<summary>
        ///Finance ammount
        ///</summary>        
        public string FinanceAmt { get; set; }

        ///<summary>
        ///Front gross
        ///</summary>        
        public string FrontGross { get; set; }

        ///<summary>
        ///Purchase of Lease MBI cost
        ///</summary>        
        public string MBICost { get; set; }

        ///<summary>
        ///MBI income
        ///</summary>        
        public string MBIIncome { get; set; }

        ///<summary>
        ///MBI limit
        ///</summary>        
        public string MBILimit { get; set; }

        ///<summary>
        ///MBI term
        ///</summary>        
        public string MBITerm { get; set; }

        ///<summary>
        ///Regular payment ammount
        ///</summary>        
        public string PaymentAmt { get; set; }

        ///<summary>
        ///Sales Posting date
        ///</summary>        
        public string SalesDate { get; set; }

        ///<summary>
        ///Type of sale
        ///</summary>        
        public string SaleType { get; set; }

        ///<summary>
        ///Sell rate exprressed as APR
        ///</summary>        
        public string SellRateAPR { get; set; }

        ///<summary>
        ///Sell rate lease money factor
        ///</summary>        
        public string SellRateLMF { get; set; }

        ///<summary>
        ///Deal type
        ///</summary>        
        public string SLSDealType { get; set; }

        ///<summary>
        ///Finance term
        ///</summary>        
        public string Term { get; set; }

        #endregion

        #region dp_customer

        /// <summary>
        /// Desc: BUYER-STREET
        /// </summary>
        public string Address { get; set; }

        /// <summary>
        ///  Buyer Date of Birth 
        /// </summary>
        public string BirthDate { get; set; }

        /// <summary>
        /// Buyer Business Phone
        /// </summary>
        public string BusinessPhone { get; set; }

        /// <summary>
        /// Buyer-city
        /// </summary>
        public string City { get; set; }

        /// <summary>
        /// Customer Number
        /// </summary>
        public string CustNo { get; set; }

        /// <summary>
        /// Home Phone
        /// </summary>
        public string HomePhone { get; set; }

        /// <summary>
        /// Name (L, F, M) Desc: BUYER-NAME
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Name (F, M, L) Desc: BUYER-NAME
        /// </summary>
        public string Name1 { get; set; }

        /// <summary>
        /// Buyer SSN
        /// </summary>
        public string SSN { get; set; }

        /// <summary>
        /// Buyer State
        /// </summary>
        public string State { get; set; }

        /// <summary>
        /// Buyer Zip
        /// </summary>
        public string ZipOrPostalCode { get; set; }

        #endregion

        #region dp_deals_payment

        /// <summary>
        /// Cash down on deal
        /// </summary>
        public string CashDown { get; set; }

        /// <summary>
        /// Initial Cap Cost
        /// </summary>
        public string InitialCapCost { get; set; }

        /// <summary>
        /// MSRP
        /// </summary>
        public string MSRP { get; set; }

        /// <summary>
        /// Rebate Amount
        /// </summary>
        public string RebateAmmount { get; set; }

        /// <summary>
        /// Security Deposit Ammount
        /// </summary>
        public string SecurityDepositAmmount { get; set; }

        /// <summary>
        /// Total cap reduction
        /// </summary>
        public string TotalCapReduction { get; set; }

        #endregion

        #region dp_lender

        /// <summary>
        /// Financial Institution Code
        /// </summary>
        public string FinInstituteCode { get; set; }

        /// <summary>
        /// Lien holder name
        /// </summary>
        public string LienHolderName { get; set; }

        #endregion

        #region dp_dealership_stock

        /// <summary>
        /// Full make name
        /// </summary>
        public string MakeName { get; set; }

        /// <summary>
        /// Full model name
        /// </summary>
        public string ModelName { get; set; }

        /// <summary>
        /// Model number of sale vehicle
        /// </summary>
        public string ModelNo { get; set; }

        /// <summary>
        /// Vehicle stock no
        /// </summary>
        public string StockNo { get; set; }

        /// <summary>
        /// Sale vehicle mileage
        /// </summary>
        public string VehicleMileage { get; set; }

        /// <summary>
        /// Vehicle Identification Number
        /// </summary>
        public string VIN { get; set; }

        #endregion

        #region dp_ext

        /// <summary>
        /// MBI-CARRIER-NAME
        /// </summary>
        public string MBICarrier { get; set; }

        /// <summary>
        /// Mechanical breakdown insurance deduction
        /// </summary>
        public string MBIDeductible { get; set; }

        /// <summary>
        /// MBI name or service contract name for lease
        /// </summary>
        public string MBIName { get; set; }

        /// <summary>
        /// MBI Policy Number
        /// </summary>
        public string MBIPolicyNo { get; set; }

        #endregion

        #region dp_deals_tradein

        /// <summary>
        /// Total Allowance
        /// </summary>
        public string TotalTradeAllowance { get; set; }

        #endregion

        #region dp_tradein

        /// <summary>
        /// Actual cash value of trade-in
        /// </summary>
        public string Trade1ACV { get; set; }

        /// <summary>
        /// Full make name of trade-in 1
        /// </summary>
        public string Trade1MakeName { get; set; }

        /// <summary>
        /// First trade-in mileage
        /// </summary>
        public string Trade1Mileage { get; set; }

        /// <summary>
        /// First trade-in model abbreviation
        /// </summary>
        public string Trade1Model { get; set; }

        /// <summary>
        /// Full model name of trade-in 1
        /// </summary>
        public string Trade1ModelName { get; set; }

        /// <summary>
        /// Trade-in allowance  
        /// </summary>
        public string Trade1Over { get; set; }

        /// <summary>
        /// Trade-in payoff
        /// </summary>
        public string Trade1PayOff { get; set; }

        /// <summary>
        /// Stock number of trade-in
        /// </summary>
        public string Trade1Stock { get; set; }

        /// <summary>
        /// Body style of trade-in 1
        /// </summary>
        public string Trade1Style { get; set; }

        /// <summary>
        /// Trade 1 VIN
        /// </summary>
        public string Trade1VIN { get; set; }

        /// <summary>
        /// First trade-in vehicle model year
        /// </summary>
        public string Trade1Year { get; set; }

        /// <summary>
        /// Actual cash value of second trade-in
        /// </summary>
        public string Trade2ACV { get; set; }

        /// <summary>
        /// Full make name of trade-in 2
        /// </summary>
        public string Trade2MakeName { get; set; }

        /// <summary>
        /// Second trade-in mileage
        /// </summary>
        public string Trade2Mileage { get; set; }

        /// <summary>
        /// Second trade-in model abbreviation
        /// </summary>
        public string Trade2Model { get; set; }

        /// <summary>
        /// Full model name of trade-in 2
        /// </summary>
        public string Trade2ModelName { get; set; }

        /// <summary>
        /// Seconde trade-in allowance
        /// </summary>
        public string Trade2Over { get; set; }

        /// <summary>
        /// Second trade-in payoff
        /// </summary>
        public string Trade2PayOff { get; set; }

        /// <summary>
        /// Stock number of second trade-in
        /// </summary>
        public string Trade2Stock { get; set; }

        /// <summary>
        /// Body style of trade-in 2
        /// </summary>
        public string Trade2Style { get; set; }

        /// <summary>
        /// Trade 2 VIN
        /// </summary>
        public string Trade2VIN { get; set; }

        /// <summary>
        /// Seconde trade-in vehicle model year
        /// </summary>
        public string Trade2Year { get; set; }

        #endregion

        #region dp_vehicle

        /// <summary>
        /// Vehicle year
        /// </summary>
        public string Year { get; set; }

        #endregion

        #region TranformationFields

        public string CoBuyerFirstName { get; set; }
        public string CoBuyerLastName { get; set; }

        public string BuyerFirstName { get; set; }
        public string BuyerLastName { get; set; }

        #endregion

        public void PrepareForTransformation()
        {
            if (!string.IsNullOrEmpty(CoBuyer))
            {
                string[] coBuyerFullName = CoBuyer.Split(' ');
                if (coBuyerFullName.Length > 0)
                    CoBuyerFirstName = coBuyerFullName[0];
                if (coBuyerFullName.Length > 1)
                    CoBuyerLastName = coBuyerFullName[1];
            }

            if (!string.IsNullOrEmpty(Name1))
            {
                string[] BuyerFullName = Name1.Split(' ');
                if (BuyerFullName.Length > 0)
                    BuyerFirstName = BuyerFullName[0];
                if (BuyerFullName.Length > 2)
                    BuyerLastName = BuyerFullName[0];
                if (BuyerFullName.Length == 2)
                    BuyerLastName = BuyerFullName[1];
            }
        }
    }
}
